package com.foreverwin.mes.so.service;


import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.foreverwin.mes.core.base.FrontPage;
import com.foreverwin.mes.core.exception.BusinessException;
import com.foreverwin.mes.so.dto.CycleTimeDeleteReq;
import com.foreverwin.mes.so.dto.InactiveTimeDto;
import com.foreverwin.mes.so.model.CycleTimeConfig;
import com.foreverwin.mes.so.model.CycleTimeConfigView;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author Syngna
 * @since 2020-01-14
 */
public interface CycleTimeConfigService extends IService<CycleTimeConfig> {

    /**
     *  分页查询
     * @param frontPage
     * @return
     */
    Page<CycleTimeConfig> selectPage(FrontPage<CycleTimeConfig> frontPage, CycleTimeConfig cycleTimeConfig);

    List<CycleTimeConfig> selectList(CycleTimeConfig cycleTimeConfig);

    List<CycleTimeConfigView> selectKeySelectiveList(CycleTimeConfigView cycleTimeConfigView);

    /**
     * <p>
     * 插入一条记录（选择字段，策略插入，防止重复插入）
     * </p>
     *
     * @param cycleTimeConfig 实体对象
     * @return boolean
     */
    boolean insert(CycleTimeConfig cycleTimeConfig);

    boolean insertBatch(List<CycleTimeConfig> entityList);

    boolean insertBatch(List<CycleTimeConfig> entityList, int batchSize);

    void deleteById(CycleTimeDeleteReq cycleTimeDeleteReq);

    void deleteBatchById(List<CycleTimeDeleteReq> requestList);

    List<CycleTimeConfig> getCycleTimeByResourceAndItem(String site, String resourceBo, String itemBo);

    @Transactional(propagation= Propagation.NOT_SUPPORTED)
    BigDecimal getCycleTime(String site, String resourceBo, String itemBo) throws BusinessException;

    List<CycleTimeConfig> selectByItemAndOperation(String site, String itemBo, String operation);

    List<InactiveTimeDto> selectInactiveTime(String site, String item);
}